package com.xhui.reggie.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xhui.reggie.common.BaseContext;
import com.xhui.reggie.common.R;
import com.xhui.reggie.dto.OrderDTO;
import com.xhui.reggie.entity.OrderDetail;
import com.xhui.reggie.entity.Orders;
import com.xhui.reggie.entity.ShoppingCart;
import com.xhui.reggie.service.OrderService;
import com.xhui.reggie.service.ShoppingCartService;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 处理订单相关接口
 * Author XHui
 * Date 2023/1/21 21:33
 * Version 1.0
 */
@RestController
@RequestMapping("/order")
public class OrderController {

    @Resource
    private OrderService orderService;


    /**
     *  提交订单
     * @param orders
     * @return
     */
    @PostMapping("/submit")
    public R<String> submit(@RequestBody Orders orders){
        orderService.submit(orders);
        return R.success("下单成功");
    }

    /**
     * 详细订单查询
     * @param page page
     * @param pageSize pageSize
     * @return
     */
    @GetMapping("/userPage")
    public R< Page<OrderDTO> > orderDetails(int page, int pageSize){
        // 查询所有订单
        return R.success(orderService.orderDetails(page, pageSize));
    }

}
